Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract fatal notification into fatalError service, add support for EuiToast notifications #15749

Merged

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented Dec 22, 2017

Relates to #15721. Partially addresses #8194. This simplifies the notification system (making it easier to integrate non-fatal notifications with EuiToasts) and adds support for displaying EuiToasts.

image

To-do

  • Make it easier to use toasts within functional tests, with data-test-subj, in a non-brittle way
  • Add Jest test coverage for GlobalToastList

Functional test changes

Avoid calling clickToastOK()

This method has traditionally been used as a hacky proxy for the successful creation of a dashboard, visualization, etc. Successful actions will trigger toasts instead of banner notifications, moving forward. So this method will become less and less useful and will eventually be removed.

Saving dashboards and visualizations is self-confirming

By the same token, now when you call saveDashboard() or saveVisualization(), the method will wait until the confirmation toast appears and resolve successfully only once it appears. This means you no longer need to call these methods and then clickToastOK() afterwards.

New getBreadcrumbPageTitle() method

The last breadcrumb behaves as a page title for many apps. This method will return the text within this breadcrumb, essentially returning the page title value.

Make string-checking tests more robust

Visualization tests now leverage this method to confirm the name of a newly-created visualization. But they do so by asserting that the value contains the name of the visualization, not that it matches it. A strict equality match is brittle and will result in a test failure if we decorate the page title with information in addition to the visualization name. But the UX is still intact so the test should not fail. Checking that the page title contains the visualization name ensures that the test will still pass in this case. We should apply similar tactics where possible.

@cjcenizal cjcenizal changed the title Extract fatal notification into fatalError service Extract fatal notification into fatalError service, remove license-checker Dec 22, 2017
@chrisronline chrisronline mentioned this pull request Dec 22, 2017
47 tasks
@cjcenizal cjcenizal changed the title Extract fatal notification into fatalError service, remove license-checker Extract fatal notification into fatalError service, remove pattern-checker Dec 22, 2017
@cjcenizal cjcenizal force-pushed the euify/notification-toasts-extract-fatal branch from 15d1300 to 28a127c Compare December 22, 2017 20:18
@cjcenizal cjcenizal changed the title Extract fatal notification into fatalError service, remove pattern-checker Extract fatal notification into fatalError service, add support for EuiToast notifications Dec 22, 2017
@cjcenizal
Copy link
Contributor Author

@nreese Could you take a look at my changes to Dashboard and let me know what you think? @thomasneirynck Could you do the same with Visualize? @bmcconaghy Would you mind doing the same with Management?

@thomasneirynck thomasneirynck self-requested a review December 26, 2017 15:50
@thomasneirynck
Copy link
Contributor

jenkins, test this

@cjcenizal cjcenizal force-pushed the euify/notification-toasts-extract-fatal branch from a14dde4 to 62ce88e Compare January 3, 2018 19:15
@@ -30,7 +30,7 @@ export function FetchNowProvider(Private, Promise) {
if (!req.started) return req;
return req.retry();
}))
.catch(courierNotifier.fatal);
.catch(error => fatalError(error, location));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like the optimizer is tripping over the uninitialized location variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shoot! Good catch, thanks. We should add a linting rule for that!

@cjcenizal cjcenizal force-pushed the euify/notification-toasts-extract-fatal branch 14 times, most recently from e08f9d5 to 0e0b7da Compare January 7, 2018 04:28
Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good from the dashboard perspective. Just a comment about using single vs double quotes.

What are the plans for all of the skipped tests?

@@ -43,7 +43,11 @@ uiRoutes
this.field = this.indexPattern.fields.byName[fieldName];

if (!this.field) {
notify.error(this.indexPattern + ' does not have a "' + fieldName + '" field.');
toastNotifications.add({
title: `"${this.indexPattern.title}" index pattern doesn't have a scripted field called "${fieldName}"`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to use single quotes to be consistent with the confirm modals?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Great catch. Will fix.

@cjcenizal
Copy link
Contributor Author

@nreese I consider this level of skipped tests to be a blocker. I'm going to dig into them to identify the cause for their failure (I have a feeling it has something to do with the clickToastOK page object method). Once I've identified the cause, I'll fix several tests spread across several functional areas. Then I'll ask each functional team if they can submit PRs into this branch fixing the remaining tests, using my solution(s) as a guideline.

@cjcenizal cjcenizal force-pushed the euify/notification-toasts-extract-fatal branch 3 times, most recently from a3d42cc to c576066 Compare January 10, 2018 00:06
@elastic elastic deleted a comment from elasticmachine Jan 26, 2018
@cjcenizal cjcenizal force-pushed the euify/notification-toasts-extract-fatal branch from b7252d9 to 545589d Compare January 26, 2018 20:31
@elasticmachine
Copy link
Contributor

💔 Build Failed

@cjcenizal
Copy link
Contributor Author

jenkins, test this

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@cjcenizal cjcenizal merged commit 6e9fc73 into elastic:master Jan 27, 2018
@cjcenizal cjcenizal deleted the euify/notification-toasts-extract-fatal branch January 27, 2018 04:14
@cjcenizal cjcenizal added Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. v7.0.0 v6.3.0 labels Jan 27, 2018
cjcenizal added a commit to cjcenizal/kibana that referenced this pull request Jan 27, 2018
…uiToast notifications (elastic#15749)

* Reorganize notify/lib files. Extract fatal notification into a fatalError service.
* Convert notify/lib tests to use Jest.
* Add ToastNotifications, GlobalToastList, and documentation.
* Remove notify.info method.
* Add createFirstIndexPatternPrompt.
* Update testSubjects.exists to accept a timeout argument.
* Skip some flaky tests.
cjcenizal added a commit that referenced this pull request Jan 28, 2018
…uiToast notifications (#15749) (#16330)

* Reorganize notify/lib files. Extract fatal notification into a fatalError service.
* Convert notify/lib tests to use Jest.
* Add ToastNotifications, GlobalToastList, and documentation.
* Remove notify.info method.
* Add createFirstIndexPatternPrompt.
* Update testSubjects.exists to accept a timeout argument.
* Skip some flaky tests.
cjcenizal added a commit to cjcenizal/kibana that referenced this pull request Jan 28, 2018
Copy link
Contributor

@gchaps gchaps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edited toast text. Format is:

object type > object name > was/were >past tense of action

@@ -183,14 +184,18 @@ app.directive('dashboardApp', function ($injector) {
$scope.addVis = function (hit, showToast = true) {
dashboardStateManager.addNewPanel(hit.id, 'visualization');
if (showToast) {
notify.info(`Visualization successfully added to your dashboard`);
toastNotifications.addSuccess('Added visualization to your dashboard');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visualization was added to your dashboard

}
};

$scope.addSearch = function (hit) {
dashboardStateManager.addNewPanel(hit.id, 'search');
notify.info(`Search successfully added to your dashboard`);
toastNotifications.addSuccess({
title: 'Added saved search to your dashboard',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saved search was added to your dashboard

@@ -268,7 +273,11 @@ app.directive('dashboardApp', function ($injector) {
.then(function (id) {
$scope.kbnTopNav.close('save');
if (id) {
notify.info(`Saved Dashboard as "${dash.title}"`);
toastNotifications.addSuccess({
title: `Saved '${dash.title}'`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dashboard '${dash.title}' was saved

@@ -416,7 +416,11 @@ function discoverController(
$scope.kbnTopNav.close('save');

if (id) {
notify.info('Saved Data Source "' + savedSearch.title + '"');
toastNotifications.addSuccess({
title: `Saved '${savedSearch.title}'`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data source "searchSearch.title" was saved

@@ -82,11 +81,17 @@ uiModules.get('apps/management')
});

if (fieldsAdded > 0) {
notify.info(fieldsAdded + ' script fields created');
toastNotifications.addSuccess({
title: 'Created script fields',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that maybe this should be "added" See the button guidelines for a description.
Also, the Kibana "Create Index" page uses "scripted field"

Recommendation:

Scripted field "fieldname" was added

or

Scripted field was added

Prefer one line over title and text

Toasts will automatically be dismissed after a brief delay, but if for some reason you want to dismiss a toast, you can use the returned toast from one of the `add` methods and then pass it to `remove`.

```js
const toast = toastNotifications.add('Saved document');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your document was saved


```js
toastNotifications.add({
title: 'Saved document',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your document was saved


```js
toastNotifications.add({
title: 'Saved document',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your document was saved

Only you have editing privileges. Edit permisson (no ending period cause its a link)


```js
toastNotifications.addSuccess({
title: 'Saved document',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your document was saved

// Select the text to be copied. If the copy fails, the user can easily copy it manually.
const copyTextarea = $document.find(selector)[0];
copyTextarea.select();

try {
const isCopied = document.execCommand('copy');
if (isCopied) {
notify.info('URL copied to clipboard.');
toastNotifications.add({
title: 'URL copied to clipboard',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL was copied to the clipboard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. v6.3.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants